﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CommunergyLogic;
using System.Web.Security;
using System.Data.Linq;
using Communergy.Repository;
using Communergy.Repository.EntityFramework;

namespace CommunergyWebApplication.Groups
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            MembershipUser thisUser = Membership.GetUser();
            if (thisUser == null)
            {
                Response.Redirect("~/");
            }
            var db = new communergyEntities();
            var userGuid = new Guid(thisUser.ProviderUserKey.ToString());
            var groupsForUser = from gu in db.GroupUser
                                where gu.gu_userId == userGuid
                                select gu.Group;
            dgGroupsForUser.DataSource = groupsForUser;
            dgGroupsForUser.DataBind();
                                

        }
    }
}
